<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- qmfcapp.cpp -->
<head>
  <title>QMfcApp Class Reference</title>
  <link href="classic.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left" valign="top" width="32"><img src="images/qt-logo.png" align="left" width="57" height="67" border="0" /></td>
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a></td>
</tr></table><h1 class="title">QMfcApp Class Reference</h1>
<p>The QMfcApp class provides merging of the MFC and Qt event loops. <a href="#details">More...</a></p>
<pre> #include &lt;QMfcApp&gt;</pre><p>Inherits <a href="http://qt.nokia.com/doc/4.6/qapplication.html">QApplication</a>.</p>
<ul>
<li><a href="qmfcapp-members.html">List of all members, including inherited members</a></li>
</ul>
<hr />
<a name="public-functions"></a>
<h2>Public Functions</h2>
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr><td class="memItemLeft" align="right" valign="top"></td><td class="memItemRight" valign="bottom"><b><a href="qmfcapp.html#dtor.QMfcApp">~QMfcApp</a></b> ()</td></tr>
</table>
<hr />
<a name="reimplemented-public-functions"></a>
<h2>Reimplemented Public Functions</h2>
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr><td class="memItemLeft" align="right" valign="top">virtual bool </td><td class="memItemRight" valign="bottom"><b><a href="qmfcapp.html#winEventFilter">winEventFilter</a></b> ( MSG * <i>msg</i>, long * <i>result</i> )</td></tr>
</table>
<ul>
<li><div bar="2" class="fn"></div>16 public functions inherited from <a href="http://qt.nokia.com/doc/4.6/qapplication.html#public-functions">QApplication</a></li>
<li><div bar="2" class="fn"></div>4 public functions inherited from <a href="http://qt.nokia.com/doc/4.6/qcoreapplication.html#public-functions">QCoreApplication</a></li>
<li><div bar="2" class="fn"></div>29 public functions inherited from <a href="http://qt.nokia.com/doc/4.6/qobject.html#public-functions">QObject</a></li>
</ul>
<hr />
<a name="static-public-members"></a>
<h2>Static Public Members</h2>
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qmfcapp.html#enterModalLoop">enterModalLoop</a></b> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qmfcapp.html#exitModalLoop">exitModalLoop</a></b> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><b><a href="qmfcapp.html#pluginInstance">pluginInstance</a></b> ( Qt::HANDLE <i>plugin</i> = 0 )</td></tr>
</table>
<ul>
<li><div bar="2" class="fn"></div>73 static public members inherited from <a href="http://qt.nokia.com/doc/4.6/qapplication.html#static-public-members">QApplication</a></li>
<li><div bar="2" class="fn"></div>38 static public members inherited from <a href="http://qt.nokia.com/doc/4.6/qcoreapplication.html#static-public-members">QCoreApplication</a></li>
<li><div bar="2" class="fn"></div>4 static public members inherited from <a href="http://qt.nokia.com/doc/4.6/qobject.html#static-public-members">QObject</a></li>
</ul>
<h3>Additional Inherited Members</h3>
<ul>
<li><div class="fn"></div>13 properties inherited from <a href="http://qt.nokia.com/doc/4.6/qapplication.html#properties">QApplication</a></li>
<li><div class="fn"></div>4 properties inherited from <a href="http://qt.nokia.com/doc/4.6/qcoreapplication.html#properties">QCoreApplication</a></li>
<li><div class="fn"></div>1 property inherited from <a href="http://qt.nokia.com/doc/4.6/qobject.html#properties">QObject</a></li>
<li><div class="fn"></div>7 public slots inherited from <a href="http://qt.nokia.com/doc/4.6/qapplication.html#public-slots">QApplication</a></li>
<li><div class="fn"></div>1 public slot inherited from <a href="http://qt.nokia.com/doc/4.6/qcoreapplication.html#public-slots">QCoreApplication</a></li>
<li><div class="fn"></div>1 public slot inherited from <a href="http://qt.nokia.com/doc/4.6/qobject.html#public-slots">QObject</a></li>
<li><div class="fn"></div>5 signals inherited from <a href="http://qt.nokia.com/doc/4.6/qapplication.html#signals">QApplication</a></li>
<li><div class="fn"></div>1 signal inherited from <a href="http://qt.nokia.com/doc/4.6/qcoreapplication.html#signals">QCoreApplication</a></li>
<li><div class="fn"></div>1 signal inherited from <a href="http://qt.nokia.com/doc/4.6/qobject.html#signals">QObject</a></li>
<li><div class="fn"></div>1 public type inherited from <a href="http://qt.nokia.com/doc/4.6/qobject.html#public-variables">QObject</a></li>
<li><div class="fn"></div>1 protected function inherited from <a href="http://qt.nokia.com/doc/4.6/qapplication.html#protected-functions">QApplication</a></li>
<li><div class="fn"></div>1 protected function inherited from <a href="http://qt.nokia.com/doc/4.6/qcoreapplication.html#protected-functions">QCoreApplication</a></li>
<li><div class="fn"></div>7 protected functions inherited from <a href="http://qt.nokia.com/doc/4.6/qobject.html#protected-functions">QObject</a></li>
<li><div class="fn"></div>2 protected variables inherited from <a href="http://qt.nokia.com/doc/4.6/qobject.html#protected-variables">QObject</a></li>
</ul>
<a name="details"></a>
<hr />
<h2>Detailed Description</h2>
<p>The QMfcApp class provides merging of the MFC and Qt event loops.</p>
<p>QMfcApp is responsible for driving both the Qt and MFC event loop. It replaces the standard MFC event loop provided by CWinApp::Run(), and is used instead of the <a href="http://qt.nokia.com/doc/4.6/qapplication.html">QApplication</a> parent class.</p>
<p>To replace the MFC event loop reimplement the CWinApp::Run() function in the CWinApp subclass usually created by the MFC Application Wizard, and use either the static run() function, or an instance of QMfcApp created earlier through the static <a href="http://qt.nokia.com/doc/4.6/qcoreapplication.html#instance">instance</a>() function or the constructor.</p>
<p>The QMfcApp class also provides a static API <a href="qmfcapp.html#pluginInstance">pluginInstance</a>() that drives the Qt event loop when loaded into an MFC or Win32 application. This is useful for developing Qt based DLLs or plugins, or if the MFC application's event handling can not be modified.</p>
<hr />
<h2>Member Function Documentation</h2>
<h3 class="fn"><a name="dtor.QMfcApp"></a>QMfcApp::~QMfcApp ()</h3>
<p>Destroys the <a href="qmfcapp.html">QMfcApp</a> object, freeing all allocated resources.</p>
<h3 class="fn"><a name="enterModalLoop"></a>void QMfcApp::enterModalLoop ()&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>Inform Qt that a modal loop is about to be entered, and that DeferredDelete events should not be processed. Call this function before calling Win32 or MFC functions that enter a modal event loop (i.e&#x2e; MessageBox).</p>
<p>This is only required if the Qt UI code hooks into an existing Win32 event loop using QMfcApp::pluginInstance.</p>
<p>See also <a href="qmfcapp.html#exitModalLoop">exitModalLoop</a>().</p>
<h3 class="fn"><a name="exitModalLoop"></a>void QMfcApp::exitModalLoop ()&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>Inform Qt that a modal loop has been exited, and that DeferredDelete events should not be processed. Call this function after the blocking Win32 or MFC function (i.e&#x2e; MessageBox) returned.</p>
<p>This is only required if the Qt UI code hooks into an existing Win32 event loop using QMfcApp::pluginInstance.</p>
<p>See also <a href="qmfcapp.html#enterModalLoop">enterModalLoop</a>().</p>
<h3 class="fn"><a name="pluginInstance"></a>bool QMfcApp::pluginInstance ( <a href="http://qt.nokia.com/doc/4.6/qt.html#HANDLE-typedef">Qt::HANDLE</a> <i>plugin</i> = 0 )&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>If there is no global <a href="http://qt.nokia.com/doc/4.6/qapplication.html">QApplication</a> object (i.e&#x2e; <a href="http://qt.nokia.com/doc/4.6/qapplication.html#qApp">qApp</a> is null) this function creates a <a href="http://qt.nokia.com/doc/4.6/qapplication.html">QApplication</a> instance and returns true; otherwise it does nothing and returns false.</p>
<p>The application installs an event filter that drives the Qt event loop while the MFC or Win32 application continues to own the event loop.</p>
<p>Use this static function if the application event loop code can not be easily modified, or when developing a plugin or DLL that will be loaded into an existing Win32 or MFC application. If <i>plugin</i> is non-null then the function loads the respective DLL explicitly to avoid unloading from memory.</p>
<pre> BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpvReserved)
 {
     if (dwReason == DLL_PROCESS_ATTACH)
         QMfcApp::pluginInstance(hInstance);

     return TRUE;
 }</pre>
<p>Set <i>plugin</i> to 0 when calling this function from within the same executable module.</p>
<p>If this function is used, call enterModalLoop and exitModalLoop whenever you call a Win32 or MFC function that opens a local event loop.</p>
<pre> void Dialog::someSlot()
 {
     QMfcApp::enterModalLoop();
     MessageBox(...);
     QMfcApp::exitModalLoop();
 }</pre>
<h3 class="fn"><a name="winEventFilter"></a>bool QMfcApp::winEventFilter ( MSG * <i>msg</i>, long * <i>result</i> )&nbsp;&nbsp;<tt> [virtual]</tt></h3>
<p>Reimplemented from <a href="http://qt.nokia.com/doc/4.6/qcoreapplication.html#winEventFilter">QCoreApplication::winEventFilter</a>().</p>
<p /><address><hr /><div align="center">
<table width="100%" cellspacing="0" border="0"><tr class="address">
<td width="30%" align="left">Copyright &copy; 2010 Nokia Corporation and/or its subsidiary(-ies)</td>
<td width="40%" align="center"><a href="http://qt.nokia.com/doc/trademarks.html">Trademarks</a></td>
<td width="30%" align="right"><div align="right">Qt Solutions</div></td>
</tr></table></div></address></body>
</html>
